﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleDBase
{
    public abstract class Data
    {
        public bool IsNull { set; get; }
        public abstract string GetValue();
    }

    public sealed class Integer : Data
    {
        public int Value { private set; get; }

        public Integer(int val, bool isnull = false)
        {
            Value = val;
            IsNull = isnull;
        }

        public override string GetValue() { return Value.ToString(); }

        public override bool Equals(object o)
        {
            return o.ToString() == this.ToString();
        }

        public override int GetHashCode()
        { 
            return this.ToString().GetHashCode();
        }

        public static bool operator ==(Integer d1, Integer d2)
        {
            return (d1.Value == d2.Value);
        }

        public static bool operator !=(Integer d1, Integer d2)
        {
            return !(d1 == d2);
        }

        public static bool operator <(Integer d1, Integer d2)
        {
            return (d1.Value < d2.Value);
        }

        public static bool operator >(Integer d1, Integer d2)
        {
            return (d1.Value > d2.Value);
        }
    }

    public sealed class Real : Data
    {
        public double Value { private set; get; }

        public Real(double val, bool isnull = false)
        {
            Value = val;
            IsNull = isnull;
        }

        public override string GetValue() { return Value.ToString(); }

        public override bool Equals(object o)
        {
            return o.ToString() == this.ToString();
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        } 

        public static bool operator ==(Real d1, Real d2)
        {
            return (d1.Value == d2.Value);
        }

        public static bool operator !=(Real d1, Real d2)
        {
            return !(d1 == d2);
        }

        public static bool operator <(Real d1, Real d2)
        {
            return (d1.Value < d2.Value);
        }

        public static bool operator >(Real d1, Real d2)
        {
            return (d1.Value > d2.Value);
        }
    }

    public sealed class Boolean : Data
    {
        public bool Value { private set; get; }

        public Boolean(bool val, bool isnull = false)
        {
            Value = val;
            IsNull = isnull;
        }

        public override string GetValue() { return Value.ToString(); }

        public override bool Equals(object o)
        {
            return o.ToString() == this.ToString();
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        } 

        public static bool operator ==(Boolean d1, Boolean d2)
        {
            return (d1.Value == d2.Value);
        }

        public static bool operator !=(Boolean d1, Boolean d2)
        {
            return !(d1 == d2);
        }
    }

    public sealed class String : Data
    {
        public string Value { private set; get; }

        public String(string val, bool isnull = false)
        {
            Value = val;
            IsNull = isnull;
        }

        public override string GetValue() { return Value; }

        public override bool Equals(object o)
        {
            return o.ToString() == this.ToString();
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        } 

        public static bool operator ==(String d1, String d2)
        {
            return (d1.Value == d2.Value);
        }

        public static bool operator !=(String d1, String d2)
        {
            return !(d1 == d2);
        }
    }
}
